home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cdity
/
ModeProSrc.lha
/
Daemon
/
MPReadArgs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-21
|
7KB
|
223 lines
#include <proto/dos.h>
#include "MP.h"
extern struct MPSem *MPSem;
extern UBYTE *Hotkey,Popup;
extern BYTE Priority;
extern STRPTR PrefsPath;
extern ULONG WBPromotable;
ULONG CenterAll;
BOOL GetReadArgs(void);
BOOL RAYesNo(STRPTR Str, BOOL DefVal);
ULONG RAInt(ULONG *Val,ULONG DefVal);
STRPTR RAString(STRPTR Str, STRPTR DefVal);
BOOL GetToolTypes(int argc, char **argv);
struct RDArgs *RArgs=NULL;
UBYTE DefPrefsPath[]="sys:prefs/ModeProPrefs";
UBYTE RATemplate[]= "CX_PRIORITY/N/K,"
"CX_POPKEY/K,"
"CX_POPUP/K,"
"PCMD=PREFSCOMMAND/K,"
"WBPROMOTABLE/S,"
"DEBUG/S";// (4.62.1)
// "NLM=NEWLOOKMENUS/S,CAH=CENTERALLHORZ/S,CAV=CENTERALLVERT/S,"
// "CPROG=CATCH_NEWPROGRAMS/S,CSCR=CATCH_NEWSCREENS/S,CPOP=CATCH_POPUP/S,"
// ",DEBUG/S";
#define RA_CX_PRIORITY 0
#define RA_CX_POPKEY 1
#define RA_CX_POPUP 2
#define RA_PREFS 3
#define RA_WBABLE 4
#define RA_DEBUG 5// (4.62.2)
LONG RAResults[6]={0};// (4.62.3)
/*
#define RA_NLM 3
#define RA_CAH 4
#define RA_CAV 5
#define RA_CPROG 6
#define RA_CSCR 7
#define RA_CPOP 8
#define RA_DEBUG 10
*/
WORD ArgMode;
struct DiskObject *MPIcon;
BOOL GetArgs(int argc, char **argv)
{
UBYTE path[512];
BPTR lock;
ArgMode=min(argc,2);
WBPromotable=0;
switch(ArgMode)
{
case 0:
return(GetToolTypes(argc,argv));
break;
case 1:
{// (4.61.2)
char pname[256];// (4.61.2)
// (4.61.2)
if(GetProgramName(pname,256))// (4.61.2)
{// (4.61.2)
if(lock=GetProgramDir())// (4.61.2)
{// (4.61.2)
if(NameFromLock(lock,path,512))// (4.61.2)
{// (4.61.2)
if(AddPart(path,pname,512))// (4.61.2)
{// (4.61.2)
if(MPIcon=GetDiskObject(path))// (4.61.2)
{// (4.61.2)
LONG l;// (4.61.2)
// (4.61.2)
for(l=0;MPIcon->do_ToolTypes[l];l++);// (4.61.2)
// (4.61.2)
return(GetToolTypes(l,MPIcon->do_ToolTypes));// (4.61.2)
}// (4.61.2)
}// (4.61.2)
}// (4.61.2)
}// (4.61.2)
}// (4.61.2)
}// (4.61.2)
return(0);
case 2:
return(GetReadArgs());
}
}
void CleanupArgs(int argc)
{
switch(ArgMode)
{
case 0:
ArgArrayDone();
break;
case 1:
ArgArrayDone();
FreeDiskObject(MPIcon);
break;
case 2:
FreeArgs(RArgs);
break;
}
}
/*
BOOL GetArgs(int argc, char **argv)
{
BOOL rv;
if(argc) //cli
rv=GetReadArgs();
else
rv=GetToolTypes(argc,argv);
return(rv);
}
void CleanupArgs(int argc)
{
if(argc)
{
if(RArgs)
FreeArgs(RArgs);
}
else
{
ArgArrayDone();
}
}
*/
BOOL GetReadArgs(void)
{
if(RArgs=ReadArgs(RATemplate,RAResults,0))
{
Hotkey =RAString((STRPTR) RAResults[RA_CX_POPKEY], Hotkey);
Popup =RAYesNo ((STRPTR) RAResults[RA_CX_POPUP], Popup);
Priority =RAInt ((ULONG *)RAResults[RA_CX_PRIORITY], Priority);
// MPSem->EnabledNLM =RAResults[RA_NLM];
// MPSem->CatchPrograms =RAResults[RA_CPROG];
// MPSem->CatchScreens =RAResults[RA_CSCR];
// MPSem->CatchPopup =RAResults[RA_CPOP];
// MPSem->CenterAll =(RAResults[RA_CAH]?1:0) + (RAResults[RA_CAV]?2:0 );
PrefsPath =RAString((STRPTR)RAResults[RA_PREFS],DefPrefsPath);
WBPromotable=RAResults[RA_WBABLE];
MPSem->Debug =RAResults[RA_DEBUG];// (4.62.4)
return(TRUE);
}
else
PrintFault(IoErr(),0);
return(FALSE);
}
BOOL RAYesNo(STRPTR Str, BOOL DefVal)
{
if(Str)
{
switch(*Str)
{
case 'T':
case 't':
case 'Y':
case 'y':
return(~0);
case 'F':
case 'f':
case 'N':
case 'n':
return(0);
}
}
return(DefVal);
}
ULONG RAInt(ULONG *Val,ULONG DefVal)
{
if(Val)
return(*Val);
return(DefVal);
}
STRPTR RAString(STRPTR Str, STRPTR DefVal)
{
if(Str)
return(Str);
return(DefVal);
}
BOOL GetToolTypes(int argc, char **argv)
{
UBYTE **ttypes;
ttypes =ArgArrayInit(argc,argv);
Hotkey =ArgString(ttypes,(UBYTE *)"CX_POPKEY", Hotkey);
Priority=ArgInt (ttypes,(UBYTE *)"CX_PRIORITY", 0);
Popup =ArgYesNo (ttypes,(UBYTE *)"CX_POPUP", TRUE);
// MPSem->EnabledNLM=ArgYesNo(ttypes,(UBYTE *)"NEWLOOKMENUS",FALSE);
// MPSem->CatchPrograms =ArgYesNo (ttypes,(UBYTE *)"CATCH_NEWPROGRAMS",FALSE);
// MPSem->CatchScreens =ArgYesNo (ttypes,(UBYTE *)"CATCH_NEWSCREENS",FALSE);
// MPSem->CatchPopup =ArgYesNo (ttypes,(UBYTE *)"CATCH_POPUP",FALSE);
PrefsPath =ArgString (ttypes,(UBYTE *)"PREFSCOMMAND", DefPrefsPath);
WBPromotable=(ULONG)ArgString(ttypes,(UBYTE *)"WBPROMOTABLE", 0);
MPSem->Debug =ArgYesNo (ttypes,(UBYTE *)"DEBUG",FALSE);// (4.62.5)
// MPSem->CenterAll =(ArgYesNo (ttypes,(UBYTE *)"CENTERALLHORZ",FALSE)?1:0) |
// (ArgYesNo (ttypes,(UBYTE *)"CENTERALLVERT",FALSE)?2:0 );
return((BOOL)ttypes);
}